package cn.gjxblog.demo2;

import org.apache.shiro.authc.*;
import org.apache.shiro.realm.AuthenticatingRealm;

import java.util.UUID;

/**
 * 作用: 自定义数据源
 * 作者:gjx
 * 版本:V1.0
 */
public class MyRealm extends AuthenticatingRealm {
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
        UsernamePasswordToken upToken = (UsernamePasswordToken)token;
        String username = upToken.getUsername();
        //模拟数据库获取用户信息
        if("xiaobai".equals(username)){
            return new SimpleAuthenticationInfo("xiaobai","123456",UUID.randomUUID().toString());
        }
        return null;
    }
}
